<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet" href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
</style>
	</ui:define>
	<ui:define name="content">
		<h:form id="form">
			<p:growl id="msgs" showDetail="true" />
			<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
				<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
				<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			</p:confirmDialog>
			<div class='full-center-content-scroll-noheader'>
				<p:toolbar id="toolbar">
					<f:facet name="left">
						<p:commandButton value="新建" id="newBtn" icon="ui-icon-document"
							actionListener="#{pushMessageTypeConfigController.preCreate}"
							rendered="#{s:hasPermission(session,'xtsz_xtzd_xxlxsz_xj')}"
							update="form2:creatDialog form:msgs editBtn" oncomplete="PF('creatDialog').show()"
							style="margin-left: 3px;" />
						<p:commandButton value="新建子节点" id="newBtn2" icon="ui-icon-document"
							actionListener="#{pushMessageTypeConfigController.preCreate}"
							rendered="#{s:hasPermission(session,'xtsz_xtzd_xxlxsz_xjzjd')}"
							disabled="#{pushMessageTypeConfigController.selectedNode == null or (!('').equals(pushMessageTypeConfigController.selected.getPid()) and pushMessageTypeConfigController.selected.getPid() != null) }"
							update="form4:creatDialog1 form:msgs editBtn" oncomplete="PF('creatDialog1').show()"
							style="margin-left: 3px;" />
						<p:commandButton value="编辑" id="editBtn" icon="ui-icon-pencil"
							disabled="#{pushMessageTypeConfigController.selectedNode == null}"
							rendered="#{s:hasPermission(session,'xtsz_xtzd_xxlxsz_bj')}"
							update=":form3:editDialog  form:msgs " style="margin-left: 3px;"
							oncomplete="PF('editDialog').show()" />
						<p:commandButton value="删除" id="deleteBtn" update="form:treeTable form:msgs form:toolbar"
							icon="ui-icon-trash" disabled="#{pushMessageTypeConfigController.selected == null}"
							rendered="#{s:hasPermission(session,'xtsz_xtzd_xxlxsz_sc')}"
							actionListener="#{pushMessageTypeConfigController.delete}" style="margin-left: 3px;">
							<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
						</p:commandButton>
					</f:facet>
				</p:toolbar>
				<p:treeTable id="treeTable" widgetVar="treeTable" emptyMessage="无记录"
					value="#{pushMessageTypeConfigController.root}" selectionMode="single"
					selection="#{pushMessageTypeConfigController.selectedNode}" var="item">
					<p:ajax event="select" update="form:toolbar"
						listener="#{pushMessageTypeConfigController.onNodeSelect}" />
					<p:ajax event="unselect" update="form:toolbar"
						listener="#{pushMessageTypeConfigController.onNodeUnSelect}" />
					<p:column headerText="名称">
						<h:outputText value="#{item.description} " />
					</p:column>
					<p:column headerText="标识符">
						<h:outputText value="#{item.id} " />
					</p:column>
				</p:treeTable>
			</div>
		</h:form>
		<h:form id="form2">
			<p:dialog id="creatDialog" widgetVar="creatDialog" header="新建" height="200" width="500"
				modal="true">
				<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
				<p:panelGrid style="width:100%">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton id="dialogSaveBtn" value="保存"
								disabled="#{!pushMessageTypeConfigController.saveCanUse}"
								actionListener="#{pushMessageTypeConfigController.saveNew}" style="margin-left:5px;"
								oncomplete="PF('creatDialog').hide()" update="form:treeTable form:msgs form:toolbar">
							</p:commandButton>
						</f:facet>
					</p:toolbar>
					<p:row>
						<p:column>
							<h:outputText value="类型名称:" />
						</p:column>
						<p:column>
							<p:inputText value="#{pushMessageTypeConfigController.created.description}"
								style="width:100%">
								<p:ajax event="blur" update="form2:dialogSaveBtn form2:typeId form2:messages"
									listener="#{pushMessageTypeConfigController.checkNameExit}" />
							</p:inputText>
						</p:column>
					</p:row>
					<p:row>
						<p:column>
							<h:outputText value="类型标识:" />
						</p:column>
						<p:column>
							<p:inputText id="typeId" style="width:100%"
								value="#{pushMessageTypeConfigController.created.id}" />
						</p:column>
					</p:row>
				</p:panelGrid>
			</p:dialog>

		</h:form>
		<h:form id="form4">
			<p:dialog id="creatDialog1" widgetVar="creatDialog1" header="新建" height="200" width="500"
				modal="true">
				<p:messages id="messages1" showDetail="true" autoUpdate="true" closable="true" />
				<p:panelGrid style="width:100%">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton id="dialogSaveBtn1" value="保存"
								disabled="#{!pushMessageTypeConfigController.saveCanUse}"
								actionListener="#{pushMessageTypeConfigController.saveNew}" style="margin-left:5px;"
								oncomplete="PF('creatDialog1').hide()" update="form:treeTable form:msgs form:toolbar">
							</p:commandButton>
						</f:facet>
					</p:toolbar>
					<p:row>
						<p:column>
							<h:outputText value="类型名称:" />
						</p:column>
						<p:column>
							<p:inputText value="#{pushMessageTypeConfigController.created.description}"
								style="width:100%">
								<p:ajax event="blur" update=":form4:dialogSaveBtn1 :form4:typeId1 :form4:messages1"
									listener="#{pushMessageTypeConfigController.getNewSubId}" />
							</p:inputText>
						</p:column>
					</p:row>
					<p:row>
						<p:column>
							<h:outputText value="类型标识:" />
						</p:column>
						<p:column>
							<p:inputText id="typeId1" style="width:100%"
								value="#{pushMessageTypeConfigController.created.id}" />
						</p:column>
					</p:row>
				</p:panelGrid>
			</p:dialog>
		</h:form>
		<h:form id="form3">
			<p:dialog id="editDialog" widgetVar="editDialog" header="编辑" height="200" width="500"
				modal="true">
				<p:panelGrid style="width:100%">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" actionListener="#{pushMessageTypeConfigController.saveEdit}"
								style="margin-left:5px;" oncomplete="PF('editDialog').hide()"
								update="form:treeTable form:msgs form:toolbar">
							</p:commandButton>
						</f:facet>
					</p:toolbar>
					<p:row>
						<p:column>
							<h:outputText value="类型名称:" />
						</p:column>
						<p:column>
							<p:inputText value="#{pushMessageTypeConfigController.selected.description}"
								style="width:100%" />
						</p:column>
					</p:row>
					<p:row>
						<p:column>
							<h:outputText value="类型标识:" />
						</p:column>
						<p:column>
							<p:outputLabel style="width:100%" value="#{pushMessageTypeConfigController.selected.id}" />
						</p:column>
					</p:row>
				</p:panelGrid>
			</p:dialog>
		</h:form>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/plugins/datatables/jquery.dataTables.js"></script>
		<script src="/resources/plugins/datatables/dataTables.bootstrap.min.js"></script>
		<script src="/resources/js/tables/mytable.js"></script>
	</ui:define>
</ui:composition>
